﻿<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
 	session_start();
	require_once("../connectMysql/connetMysql.class.php");
	$mobile=$_POST['mobile'];
	$password=md5($_POST['pass']);
	$rename=$_POST['rename'];
	date_default_timezone_set('PRC');
    	$curtime=date("Y-m-d h:i:s");
	$db=new connetMysql;
	$con=$db->getConnect();
	$chk_sql="SELECT * FROM user WHERE UserPhone='".$mobile."'";	
	mysqli_query($con,$chk_sql);
	$num=mysqli_affected_rows($con);
	
	if($num==0)
	{
		$sql = "INSERT INTO user(UserName,Password,UserPhone,RegisterTime) VALUES('".$rename."','".$password."','".$mobile."','".$curtime."')";
		$_SESSION["mb"]=$mobile;
		$_SESSION["pwd"]=$password;
		setcookie("mb",$mobile,time() + (60*60*24*7),"/"); 
        setcookie("w", $password,time() + (60*60*24*7),"/");
		$result = mysqli_query($con,$sql);
		$con->close(); 
		echo "<script>alert('注册成功！');</script>";
		echo "<script>window.location.href='../people/person.php'</script>";
		
	}
	else 
	{
		$con->close(); 
		echo "<script>alert('手机已经注册');</script>";
		echo "<script>window.location.href='../me/me.php'</script>";
		
		
		exit;
	}
	
?>